import {BasicColumn} from '/@/components/Table';
import {FormSchema} from '/@/components/Table';
import { render } from '/@/utils/common/renderUtils';
import {JVxeTypes,JVxeColumn} from '/@/components/jeecg/JVxeTable/types'
import {DescItem, useDescription } from '/@/components/Description/index';
//列表数据
export const columns: BasicColumn[] = [
   
   {
    title: '主题名称',
    align:"center",
    dataIndex: 'themeName'
   },
   {
    title: '学期',
    align:"center",
    dataIndex: 'semesterId_dictText'
   },
   {
    title: '有效开始时间',
    align:"center",
    dataIndex: 'beginDate',
    customRender:({text}) =>{
      return !text?"":(text.length>10?text.substr(0,10):text)
    },
   },
   {
    title: '有效结束时间',
    align:"center",
    dataIndex: 'endDate',
    customRender:({text}) =>{
      return !text?"":(text.length>10?text.substr(0,10):text)
    },
   },
   {
    title: '创建日期',
    align:"center",
    dataIndex: 'createTime'
   },
   {
    title: '更新日期',
    align:"center",
    dataIndex: 'updateTime'
   },
   {
    title: '备注',
    align:"center",
    dataIndex: 'remark'
   }
];
//查询数据
export const searchFormSchema: FormSchema[] = [
  {
    label: "学期",
    field: 'semesterId',
    component: 'JDictSelectTag',
    componentProps:{
      dictCode:"cs_semester where del_flag=0 and status=1 order by id desc,name,id"
    },
    //colProps: {span: 6},
  },
	{
      label: "主题名称",
      field: 'themeName',
      component: 'JInput',
      //colProps: {span: 6},
 	},
];
//表单数据
export const formSchema: FormSchema[] = [
  {
    label: '主题名称',
    field: 'themeName',
    component: 'Input',
    dynamicRules: ({model,schema}) => {
          return [
                 { required: true, message: '请输入主题名称!'},
          ];
     },
      colProps: {span: 24},
  },
  {
    label: "学期",
    field: 'semesterId',
    component: 'JDictSelectTag',
    required:true,
    componentProps:{
      stringToNumber:true,
      dictCode:"cs_semester where del_flag=0 and status=1 order by id desc,name,id"
    },
    colProps: {span: 24},
  },
  {
    label: '有效时间',
    field: 'beginAndEndDate',
    component: 'RangeDate',
    componentProps: {
      //日期格式化
      format:'YYYY-MM-DD',
      //范围文本描述用集合
    },
    colProps: {span: 24},
    dynamicRules: ({model,schema}) => {
          return [
                 { required: true, message: '请输入有效开始时间!'},
          ];
     },
  },
  {
    label: '备注',
    field: 'remark',
    component: 'Input',
    colProps: {span: 24},
  },
	// TODO 主键隐藏字段，目前写死为ID
	{
	  label: '',
	  field: 'id',
	  component: 'Input',
	  show: false
	},
];

export const subjectColumns: JVxeColumn[] = [
   
  {
   title: '科目',
   align:"center",
   key: 'courseId',
   type: JVxeTypes.selectSearch,
   options:[],
   dictCode:"cs_courses,name,id,del_flag=0",
   placeholder: '请选择${title}',
   validateRules: [
    {
      required: true, // 必填
      message: '请选择${title}', // 显示的文本
    },
    {
      unique: true,
      message: '${title}不能重复',
    }]
  },
  {
   title: '上课日',
   align:"center",
   key: 'attendClassWork',
   type: JVxeTypes.selectMultiple,
   placeholder: '请选择',
   options: [
    { title: '周一', value: '1' },
    { title: '周二', value: '2' },
    { title: '周三', value: '3' },
    { title: '周四', value: '4' },
    { title: '周五', value: '5' },
    { title: '周六', value: '6' },
    { title: '周日', value: '0' },
  ],
  // allowInput: true,
  allowSearch: true,
  validateRules: [
    {
      required: true, // 必填
      message: '请输入${title}', // 显示的文本
    }]
  },
  /*
  {
   title: '费用',
   align:"center",
   key: 'cost',
   width:80,
   type: JVxeTypes.slot,
   slotName:'costSlot',
   disabled:true,
   placeholder: '请输入${title}',
   validateRules: [
    {
      required: true, // 必填
      message: '请输入${title}', // 显示的文本
    }]
  },
  */
  {
   title: '总份数',
   align:"center",
   key: 'cntCopies',
   type: JVxeTypes.inputNumber,
   width:100,
   placeholder: '0不限制',
   validateRules: [
    {
      required: true, // 必填
      message: '请输入${title}', // 显示的文本
    }]
  },
  {
   title: '选择方式',
   align:"center",
   key: 'choseType',
   type: JVxeTypes.radio,
   width:150,
   defaultValue: '1',
   options: [
    { text: '选交', value: '1'},
    { text: '必交', value: '2' },
  ]
  },
  {
   title: '其他',
   align:"center",
   key: 'valOther',
   placeholder: '勾选时排除项',
   type: JVxeTypes.selectSearch,
   options:[],
   dictCode:"cs_courses,name,id,del_flag=0"
  },
  {
    title: '操作',
    type: JVxeTypes.slot,
    width:100,
    align: 'center',
    slotName: 'myAction'
   }
];

export const descItemDetailColumns: DescItem[] = [
  {
    label: '主题名称',
    field: 'themeName'
   },
   {
    label: '有效开始时间',
    field: 'beginDate'
   },
   {
    label: '有效结束时间',
    field: 'endDate'
   },
   {
    label: '创建日期',
    field: 'createTime'
   },
   {
    label: '更新日期',
    field: 'updateTime'
   }
];

/**430退课  所退科目订单 列表*/
export const refundPersonColumns: BasicColumn[]=[
  {
    title: '学号',
    align:"center",
    dataIndex: 'code'
   },
   {
    title: '姓名',
    align:"center",
    dataIndex: 'name'
   },
   {
     title: '部门',
     align:"center",
     dataIndex: 'departmentId_dictText'
    },
    {
      title: '科目名称',
      align:"center",
      dataIndex: 'courseId_dictText'
     },
    {
     title: '支付金额',
     align:"center",
     dataIndex: 'money'
    },
    {
     title: '支付时间',
     align:"center",
     dataIndex: 'createTime'
    },
   {
    title: '订单状态',
    align:"center",
    dataIndex:'status',
    customRender:({text}) =>{
      return render.renderDict(text, 'detail_status');
    },
   },
   {
    title: '总节数',
    align:"center",
    dataIndex: 'cnt'
   },
   {
    title: '已完成数',
    align:"center",
    dataIndex: 'normal'
   },
   {
    title: '已退课数',
    align:"center",
    dataIndex: 'unsub'
   },
]
/**430退课  所退科目订单 搜索*/
export const searchRefundPersonSchema:FormSchema[]=[
  {
    label: "学号",
    field: 'code',
    component: 'Input',
 },
 {
  label: "姓名",
  field: 'name',
  component: 'JInput',
 }
]


// 高级查询数据
export const superQuerySchema = {
  createBy: {title: '创建人',order: 0,view: 'text', type: 'string',},
  createTime: {title: '创建日期',order: 1,view: 'datetime', type: 'string',},
  updateTime: {title: '更新日期',order: 2,view: 'datetime', type: 'string',},
  themeName: {title: '主题名称',order: 3,view: 'text', type: 'string',},
  beginDate: {title: '有效开始时间',order: 4,view: 'datetime', type: 'string',},
  endDate: {title: '有效结束时间',order: 5,view: 'datetime', type: 'string',},
  remark: {title: '备注',order: 6,view: 'text', type: 'string',},
};

/**
* 流程表单调用这个方法获取formSchema
* @param param
*/
export function getBpmFormSchema(_formData): FormSchema[]{
  // 默认和原始表单保持一致 如果流程中配置了权限数据，这里需要单独处理formSchema
  return formSchema;
}